Skip to content

fix: dereference typed pointers in VML models safely - #39

Merged
medvednikov merged 1 commit into
masterfrom
fix/issue-25-20260919
Sep 19, 2026
Merged

medvednikov merged 1 commit into
masterfrom
fix/issue-25-20260919

Conversation

@medvednikov

Copy link
Copy Markdown
Member

Fixes #25.

Changes

Automatically dereference typed pointers during VML model value and schema conversion, allowing expressions such as app.counter.count when counter is &Counter. Preserve the existing conversion behavior for scalar, struct, and array values.

Handle nil references without dereferencing them, and track ancestor addresses to avoid infinitely traversing cyclic object graphs while still permitting shared references. Schema conversion can inspect declared pointee types for nil references and empty pointer arrays. Include explicit handling for multiple pointer indirections supported by V 0.5.2.

Tests cover live values after actions, nested/shared/cyclic references, unused nil fields, nil-path diagnostics, empty and populated pointer arrays, invalid fields, scalar pointers, and multiple nil indirections.

Applications must still initialize references they intend to read (for example, counter: &Counter{}). This change does not allocate objects for nil pointers, make cyclic back-edges readable, or add pointer-target two-way writes.

Verification

Passed with V 0.5.2:

v -d ui2_headless test ui/vml_pointer_model_test.v
v -d ui2_headless test ui/vml_model_test.v

The regression fails against the original implementation and passes with this change. These commands also passed on Linux before branch publication: verification log. The shared run later stopped on an existing scrolling-test compilation failure for another issue.

Pointer regression tests also passed locally under AddressSanitizer (-cc gcc -gc none, leak detection disabled). No temporary verification infrastructure is included in this PR.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 19, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-19T14:05:12.585224Z a081bc9 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a081bc9629

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread ui/vml_model.v
Comment on lines +71 to +72
address := unsafe { voidptr(value) }
if isnil(value) || address in ancestors {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Distinguish pointee types when detecting cycles

When a pointer targets the first field of an ancestor struct, its address is normally identical to the struct's address, so this address-only check incorrectly treats the interior pointer as a cyclic back-edge. For example, if Counter has count int followed by count_ref &int and count_ref = &counter.count, converting &counter makes count_ref invalid instead of exposing the number; the analogous check in v_schema_from_tracked also rejects app.counter.count_ref during validation. Track the pointee type together with the address (or otherwise distinguish interior pointers from actual back-edges).

Useful? React with 👍 / 👎.

@medvednikov
medvednikov merged commit b7c4c2d into master Sep 19, 2026
0 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot use pointers in UI model

1 participant